package com.oocl.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DBUtil {

	private static final String CLASSNAME = "oracle.jdbc.OracleDriver";
	private static final String URL = "jdbc:oracle:thin:@10.222.29.165:1521:xe";
	private static final String USER = "matthew";
	private static final String PWD = "123456";

	public static Connection getConnection() {
		Connection con = null;
		try {
			Class.forName(CLASSNAME);
			con = DriverManager.getConnection(URL, USER, PWD);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return con;

	}
	
	public static void release(Connection con, Statement stm, ResultSet rs){
		try {
			if(con != null){
				con.close();
			}
			if(stm != null){
				stm.close();
			}
			if(rs != null){
				rs.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}
